package com.app.shortvideo.startup

import android.content.Context
import android.util.Log
import com.app.shortvideo.BuildConfig.DEBUG
import com.app.shortvideo.R
import com.bytedance.sdk.shortplay.api.PSSDK
import com.bytedance.sdk.openadsdk.api.init.PAGConfig
import com.bytedance.sdk.openadsdk.api.init.PAGSdk
import com.rousetime.android_startup.AndroidStartup


class FirstStartUp: AndroidStartup<Boolean>() {
    override fun create(context: Context): Boolean? {
//        ConfigManager.getInstance()?.getServerConfigInfo();
        val appId = "8309530"
        val securityKey = "82dc912698c9e4e7cd8176da48906fde"

        val builder = PSSDK.Config.Builder()
        builder.appId(appId)
            .vodAppId("568708")
            .securityKey(securityKey)
            .licenseAssertPath("stand.lic")
            .debug(true)
            PSSDK.init(context, builder.build(),{ success, errorInfo ->
            if (DEBUG) {
              Log.d("PSSDK:", "onInitFinished() called with: success = [" + success +"], errorInfo = [" + errorInfo + "]")
            }
           })
        PSSDK.setEligibleAudience(true);
        initPangleAdsSDK(context);
        return true
    }
    private fun initPangleAdsSDK(context: Context) {
        val builder: PAGConfig.Builder = PAGConfig.Builder()
        builder.appId("8025677").appIcon(R.mipmap.ic_launcher)
        PAGSdk.init(context, builder.build(), object : PAGSdk.PAGInitCallback {
            override fun success() {
                Log.d("PAGSdk:", "pangle ads sdk init success")
            }

            override fun fail(i: Int, s: String) {
                Log.d("PAGSdk:", "pangle ads sdk init fail, i=$i, s=$s")
            }
        })
    }
    override fun callCreateOnMainThread(): Boolean {
        return false
    }

    override fun waitOnMainThread(): Boolean {
        return false
    }
}